package com.anbang.app.ui.frame.study.recycleView.adapter

import android.view.ViewGroup
import com.ab.filemanager.base.adapter.BaseRecycleViewAdapter
import com.ab.filemanager.base.adapter.BaseViewHolder
import kotlin.collections.ArrayList

/**
 * 创建作者：AnBang
 * 创建时间：2018/9/13
 * 功能描述：通用简单展示适配器
 */
class CommonItemAdapter(val list: ArrayList<*>, private val viewHolder: ((ViewGroup) -> BaseViewHolder)) : BaseRecycleViewAdapter() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
        //return FriendItemViewHolder(mActivity, mActivity.layoutInflater.inflate(R.layout.item_friend, parent, false))
        return viewHolder.invoke(parent)
    }

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        holder.bindViewHolder(list[position])
    }
}